﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OracleClient;
public partial class book_select : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindData();
        }
    }
    public void BindData()
    {
        string connet = "Data Source=orcl;User ID=booksale;Password=Qwertyuiop1;Unicode=True";
        string sqlstr = "select * from booksale.Book_infor order by 编号";
        OracleConnection con = new OracleConnection(connet);
        OracleDataAdapter da = new OracleDataAdapter(sqlstr, con);
        DataSet ds = new DataSet();
        da.Fill(ds);
        G1.DataSource = ds;
        G1.DataKeyNames = new string[] { "编号" };
        G1.DataBind();


    }
    protected void Button1_Click(object sender, EventArgs e)
    {

        string connet = "Data Source=orcl;User ID=booksale;Password=Qwertyuiop1;Unicode=True";
        string sqlstr = "select * from booksale.Book_infor where 编号='" + booknum.Text + "' or 名称='" + bookname.Text + "'";
        OracleConnection con = new OracleConnection(connet);
        OracleDataAdapter da = new OracleDataAdapter(sqlstr, con);
        DataSet ds = new DataSet();
        da.Fill(ds);
        G1.DataSource = ds;
        G1.DataKeyNames = new string[] { "编号" };
        G1.DataBind();
    }

    protected void G1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        G1.PageIndex = e.NewPageIndex;
        BindData();
    }
}